﻿namespace LL.Common
{
    public static class ConditionGroupExtensions
    {
        public static IConditionGroup Group(this IConditionGroup group, string column, Comparison op, object value = null)
        {
            return group.AndGroup(CreateCondition(column, op, value));
        }
        public static IConditionGroup And(this IConditionGroup group, string column, Comparison op, object value = null)
        {
            return group.And(CreateCondition(column, op, value));
        }
        public static IConditionGroup Or(this IConditionGroup group, string column, Comparison op, object value = null)
        {
            return group.Or(CreateCondition(column, op, value));
        }

        private static IConditionItem CreateCondition(string column, Comparison op, object value)
        {
            return new KeyValueCondition { ColumnName = column, Operator = op, Value = value };
        }
    }
}